// pages/my/my.js
var app = getApp();
var ea = require('../../utils/each.js');
var time = require('../../utils/util.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {

    getmyUrl: app.data.url + 'zhongxue/teacher/my',
    shuju:{},

    myUrl:[
      "/img/27.png"
    ],
    headerUrl:[
      "/img/6.png"
    ],
    message:[
      {
        name:"陈老师",
        url:"/img/baf38bd8c030f8b27599a2e8f469b72.png",
        uname:"任职校区"
      }
    ],
    dataUrl:[
      "/img/51.png"
    ],
    nannv: [
      { url: app.data.url + 'uploads/laoshi/f3491edaff6affe7f65c06e6c686218.png'},
      { url: app.data.url + 'uploads/laoshi/baf38bd8c030f8b27599a2e8f469b72.png'}
      ],
    title:[
      {
        phase:"任职学段",
        stage:"小学",
        
       
      },
      {
        phase: "任职科目",
        stage: "语文",
      },
      {
        phase: '任职时间',
        stage: "2年"
      },
    ],
    brief:[
      {
        name:"个人简介",
        uname:"本人任职多年，性格严厉，有责任心，对待每一位同学都尽职尽责，多年的授课经验让我积累了很多丰富的教学经验，获得了成都市青羊区十大优秀教师称号和先进教师称号。"
      }
    ]
  },
  quit:function(){
    wx.showModal({
      title: '提示',
      content: '确定要退出登录吗',
      success:function(res){
        if(res.confirm){
          wx.reLaunch({
            url: '/pages/register/register',
          })
          wx.setStorageSync('newuser', '')
        }else{
          console.log('用户点击取消')
        }
      }
    })
  },
  skip:function(){
    wx.navigateTo({
      url: '/pages/compile/compile',
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  },



  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var user = wx.getStorageSync('newuser');
    var that = this;
    console.log(user);
    if(!user){
      wx.showModal({
        title: '提示',
        content: '你还没有登录点击确定登录',
        success: function (res) {
          if (res.confirm) {
            wx.navigateTo({
              url: '/pages/register/register',
            })
          } else {
            console.log('用户点击取消')
          }
        }

      })
    }else{
      var token = user.token
      var shenhe = user.shenhe
      console.log(token)
      wx.request({
        url: that.data.getmyUrl,
        method: 'post',
        data: { token: token, shenhe: shenhe },
        success: function (res) {
          var data = res.data;
          console.log(data)
          if(data.code==200){
            var shuju = data.data
            that.setData({shuju:shuju})
            console.log('获取成功 ')
          }else{
            wx.navigateTo({
              url: '/pages/register/register',
              success: function(res) {},
              fail: function(res) {},
              complete: function(res) {},
            })
            if (data.code == 205) {
              wx.showToast({
                title: '该账号未通过审核',
                icon: 'none',
              })
              // return
            }
            // console.log('获取失败')
          }
        }
      })
    }
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})